import axios from 'axios';
export function getUser(data,id){
	console.log('userid=',id);
	return dispatch=>{
		dispatch(fetchUserData(data))
		axios.get(`https://cnodejs.org/api/v1/user/${id}`)
		.then(res=>{
			console.log('result',res);
			dispatch(reciveUserData(res.data.data));
		})
		.catch(error=>{
			console.log(error)
			dispatch(fetchUserError());
		})
	}
	
}
function reciveUserData(data){
	return {
		type: 'USER_UPDATE_SUCC',
		data
	}
}
function fetchUserData(data) {
	return {
		type: "USER_UPDATE",
		loading: true,
		data: data
	}
}
function fetchUserError() {
	return {
		type: "USER_UPDATE_ERROR"
	}
}